if(sessionStorage.getItem('user')){
    var user=JSON.parse(sessionStorage.getItem('user'));
    if(!(window.name==user.name)){
        window.name=user.name;
        $('#tiShi').text('登录成功');
        tiShi()
    }
}else{
    window.location.href='login.html';
}
$('#gongGaoZhuYe').on('click',function(){
    $('.s1>div').css('display','none');
    $('#page1').css('display','block');
    gongGaoZhuYe();
})
$('#suSheGuanLi').on('click',function(){
    if(!user.type){
        window.location.href='login.html';
    }
    $('.s1>div').css('display','none');
    $('#page2').css('display','block');
    suSheGuanLi();
})
$('#xueShengGuanLi').on('click',function(){
    $('.s1>div').css('display','none');
    $('#page3').css('display','block');
    xueShengGuanLi();
})
$('#gongGaoGuanLi').on('click',function(){
    if(!user.type){
        window.location.href='login.html';
    }
    $('.s1>div').css('display','none');
    $('#page4').css('display','block');
    gongGaoGuanLi();
})
$('#guanLiYuanGuanLi').on('click',function(){
    if(!user.type){
        window.location.href='login.html';
    }
    $('.s1>div').css('display','none');
    $('#page5').css('display','block');
    guanLiYuanGuanLi();
})
var arr=[];
var count=5;
var page=1;
var getId=0;
var getType='';
var allSuShe=[];
var dormIdArr=[];
var stuIdArr=[];
var userIdArr=[];
var chuShiPosition={left:0,top:0};
var chuShiMargin={left:0,top:0};
gongGaoZhuYe();
function gongGaoZhuYe(){
    arr=[];
    count=5;
    page=1;
    if($('.index1').length==0){
        $('.index0').before('<li class="index1"><a href="javascript:;">公告主页<span class="j-del">×</span></a></li>');
    }
    $('.biaoqianye>li').attr('data-class','');
    $('.index1').attr('data-class','active');
    $('.s1>div>div>input').val('');
    $('.yanZheng').text('');
    $.ajax({
        url:'/api/notice/getnotice',
        success:function(res){
            if(res.data.length){
                $.each(res.data,function(i,v){
                    arr.push(v);
                });
                creatYeMa(1);
                xuanRanGongGao();
                $('#page1 .yema').removeClass('active');
                $('#page1 .yema').eq(0).addClass('active');
            }  
        }
    });
}
function xuanRanGongGao(){
    $('.gonggaolan').html('');
    for(var i=(page-1)*count;i<page*count;i++){
        if(i>=arr.length){
            break;
        }
        $('.gonggaolan').append('<li>\
        <p>'+arr[i].title+'</p>\
        <p>'+arr[i].mytime+'</p>\
        <p>'+arr[i].content+'</p>\
    </li>');
    }
}
function creatYeMa(p){
    $('#page'+p+' .pages ul').html('');
    $('#page'+p+' .pages ul').append($('<li>\
    <a href="javascript:;" aria-label="Previous" class="toPrevious">\
        <span aria-hidden="true">&laquo;</span>\
    </a>\
</li>\
<li class="next">\
    <a href="javascript:;" aria-label="Next" class="toNext">\
        <span aria-hidden="true">&raquo;</span>\
    </a>\
</li>'));
    for(var i=1;i<=Math.ceil(arr.length/count);i++){
        $('#page'+p+' .next').before($('<li><a href="javascript:;" class="yema">'+i+'</a></li>'))
    }
    $('#page'+p+' .pages').on('click','a',function(){
        toPage(p,this);
    });
}
function toPage(p,_this){
    if($(_this).attr('class')=='yema'){
        page=$(_this).text();
        $('#page'+p+' .yema').removeClass('active');
        $(_this).addClass('active');
        runFn(p);
    }else if($(_this).attr('class')=='toNext'){
        if(!(page==Math.ceil(arr.length/count))){
            page++;
            $('#page'+p+' .yema').removeClass('active');
            $('#page'+p+' .yema').eq(page-1).addClass('active');
            runFn(p);
        }
    }else if($(_this).attr('class')=='toPrevious'){
        if(!(page==1)){
            page--;
            $('#page'+p+' .yema').removeClass('active');
            $('#page'+p+' .yema').eq(page-1).addClass('active');
            runFn(p);
        }
    }
}
function runFn(p){
    switch(p){
        case 1:xuanRanGongGao();
        break;
        case 2:xuanRanSuShe();
        break;
        case 3:xuanRanXueSheng();
        break;
        case 4:xuanRanGongGao2();
        break;
        case 5:xuanRanGuanLiYuan();
        break;
    }
}
function suSheGuanLi(){
    arr=[];
    count=5;
    page=1;
    if($('.index2').length==0){
        $('.index0').before('<li class="index2"><a href="javascript:;">宿舍管理<span class="j-del">×</span></a></li>');
    }
    $('.biaoqianye>li').attr('data-class','');
    $('.index2').attr('data-class','active');
    $('.s1>div>div>input').val('');
    $('.yanZheng').text('');
    $.ajax({
        url:'/api/dorm/getdorm',
        success:function(res){
            if(res.data.length){
                $.each(res.data,function(i,v){
                    arr.push(v);
                });
                creatYeMa(2);
                xuanRanSuShe();
                $('#page2 .yema').removeClass('active');
                $('#page2 .yema').eq(0).addClass('active');
            }  
        }
    });
}
function xuanRanSuShe(){
    var typeName='';
    var aTagName='';
    $('#page2 table').html('');
    $('#page2 table').append('<tr>\
    <th>宿舍编号</th>\
    <th>宿舍名称</th>\
    <th>宿舍人数</th>\
    <th>宿舍水电费余额（元）</th>\
    <th>宿舍状态</th>\
    <th>操作</th>\
</tr>');
    for(var i=(page-1)*count;i<page*count;i++){
        if(i>=arr.length){
            break;
        }
        if(arr[i].type==1){
            typeName='正常';
            aTagName='发起催款申请';
        }else{
            typeName='催款中';
            aTagName='修改为正常状态';
        }
        $('#page2 table').append('<tr>\
        <td data-id="'+arr[i].id+'">'+arr[i].dormId+'</td>\
        <td>'+arr[i].dormName+'</td>\
        <td>'+arr[i].num+'</td>\
        <td>'+arr[i].balance+'</td>\
        <td>'+typeName+'</td>\
        <td><a href="javascript:;">删除</a>&nbsp;<a href="javascript:;">修改</a>&nbsp;<a href="javascript:;">'+aTagName+'</a></td>\
        </tr>');
    }
}
function xueShengGuanLi(){
    arr=[];
    count=5;
    page=1;
    allSuShe=[];
    if($('.index3').length==0){
        $('.index0').before('<li class="index3"><a href="javascript:;">学生管理<span class="j-del">×</span></a></li>');
    }
    $('.biaoqianye>li').attr('data-class','');
    $('.index3').attr('data-class','active');
    $('.s1>div>div>input').val('');
    $('.yanZheng').text('');
    $.ajax({
        url:'/api/dorm/getdorm',
        success:function(res){
            if(res.data.length){
                $.each(res.data,function(i,v){
                    allSuShe.push(v);
                });
            }  
        }
    });
    $.ajax({
        url:'/api/student/getstudent',
        success:function(res){
            if(res.data.length){
                $.each(res.data,function(i,v){
                    arr.push(v);
                });
                if(user.type){
                    creatYeMa(3);
                    xuanRanXueSheng();
                    $('#page3 .yema').removeClass('active');
                    $('#page3 .yema').eq(0).addClass('active');
                }else{
                    xuanRanXueSheng();
                }
            }  
        }
    });
    if(!user.type){
        $('#page3').css('padding-top','50px');
        $('#page3>div').css('display','none');
        $('#xiuGaiXueSheng>div:nth-of-type(3) input').attr('disabled','disabled');
        $('.suoShuSuSheXiaLa>ul').css('height','27px')
    }
}
function xuanRanXueSheng(){
    var typeName='';
    $('#page3 table').html('');
    $('#page3 table').append('<tr>\
    <th>学号</th>\
    <th>姓名</th>\
    <th>账号</th>\
    <th>学生所属宿舍</th>\
    <th>宿舍水电费余额（元）</th>\
    <th>宿舍状态</th>\
    <th>操作</th>\
</tr>');
    for(var i=(page-1)*count;i<page*count;i++){
        if(i>=arr.length){
            break;
        }
        if(arr[i].type==1){
            typeName='正常';
        }else{
            typeName='催款中'
        }
            $('#page3 table').append('<tr>\
            <td data-id="'+arr[i].id+'" data-pass="'+arr[i].stuPas+'">'+arr[i].stuId+'</td>\
            <td>'+arr[i].stuName+'</td>\
            <td>'+arr[i].stuUserId+'</td>\
            <td>'+arr[i].dormId+'</td>\
            <td>'+arr[i].balance+'</td>\
            <td>'+typeName+'</td>\
            <td><a href="javascript:;">删除</a>&nbsp;<a href="javascript:;">修改</a>&nbsp;<a href="javascript:;">查看缴费记录</a></td>\
        </tr>');
    }
    $('.suoShuSuSheXiaLa>ul').html('');
    var dormIdList=[];
    for(var i=0;i<allSuShe.length;i++){
        var boolean=true;
        for(var j=0;j<dormIdList.length;j++){
            if(allSuShe[i].dormId==dormIdList[j]){
                boolean=false;
                break;
            }
        }
        if(boolean){
            dormIdList.push(allSuShe[i].dormId);
        }
    }
    for(var i=0;i<dormIdList.length;i++){
        $('.suoShuSuSheXiaLa>ul').append('<li>'+dormIdList[i]+'</li>');
    }
    if(!user.type){
        $('#page3 table').html('');
        $('#page3 table').append('<tr>\
        <th>学号</th>\
        <th>姓名</th>\
        <th>账号</th>\
        <th>学生所属宿舍</th>\
        <th>宿舍水电费余额（元）</th>\
        <th>宿舍状态</th>\
        <th>操作</th>\
    </tr>');
        for(var i=0;i<arr.length;i++){
            if(arr[i].stuUserId==user.stuUserId){
                if(arr[i].type==1){
                    typeName='正常';
                }else{
                    typeName='催款中'
                }
                $('#page3 table').append('<tr>\
                <td data-id="'+arr[i].id+'" data-pass="'+arr[i].stuPas+'">'+arr[i].stuId+'</td>\
                <td>'+arr[i].stuName+'</td>\
                <td>'+arr[i].stuUserId+'</td>\
                <td>'+arr[i].dormId+'</td>\
                <td>'+arr[i].balance+'</td>\
                <td>'+typeName+'</td>\
                <td><a href="javascript:;"></a>&nbsp;<a href="javascript:;">修改</a>&nbsp;<a href="javascript:;">查看缴费记录</a></td>\
            </tr>');
                $('.suoShuSuSheXiaLa>ul').html('');
                $('.suoShuSuSheXiaLa>ul').append('<li>'+arr[i].dormId+'</li>');
                break;
            }
        }
    }
}
function gongGaoGuanLi(){
    arr=[];
    count=5;
    page=1;
    if($('.index4').length==0){
        $('.index0').before('<li class="index4"><a href="javascript:;">公告管理<span class="j-del">×</span></a></li>');
    }
    $('.biaoqianye>li').attr('data-class','');
    $('.index4').attr('data-class','active');
    $('.s1>div>div>input').val('');
    $('.yanZheng').text('');
    $.ajax({
        url:'/api/notice/getnotice',
        success:function(res){
            if(res.data.length){
                $.each(res.data,function(i,v){
                    arr.push(v);
                });
                creatYeMa(4);
                xuanRanGongGao2();
                $('#page4 .yema').removeClass('active');
                $('#page4 .yema').eq(0).addClass('active');
            }  
        }
    });
}
function xuanRanGongGao2(){
    $('#page4 table').html('');
    $('#page4 table').append('<tr>\
    <th>公告编号</th>\
    <th>公告标题</th>\
    <th>公告内容</th>\
    <th>发布时间</th>\
    <th>发布人</th>\
    <th>操作</th>\
</tr>');
    for(var i=(page-1)*count;i<page*count;i++){
        if(i>=arr.length){
            break;
        }
        $('#page4 table').append('<tr>\
        <td>'+arr[i].id+'</td>\
        <td>'+arr[i].title+'</td>\
        <td><p title="'+arr[i].content+'">'+arr[i].content+'</p></td>\
        <td>'+arr[i].mytime+'</td>\
        <td>'+arr[i].name+'</td>\
        <td><a href="javascript:;">删除</a>&nbsp;<a href="javascript:;">修改</a></td>\
    </tr>');
    }
}
function guanLiYuanGuanLi(){
    arr=[];
    count=5;
    page=1;
    $('.s1>div>div>input').val('');
    $('.yanZheng').text('');
    if($('.index5').length==0){
        $('.index0').before('<li class="index5"><a href="javascript:;">管理员管理<span class="j-del">×</span></a></li>');
    }
    $('.biaoqianye>li').attr('data-class','');
    $('.index5').attr('data-class','active');
    $.ajax({
        url:'/api/admin/getadmin',
        success:function(res){
            if(res.data.length){
                $.each(res.data,function(i,v){
                    arr.push(v);
                });
                if(user.type==1){
                    xuanRanGuanLiYuan();
                }else{
                    creatYeMa(5);
                    xuanRanGuanLiYuan();
                    $('#page5 .yema').removeClass('active');
                    $('#page5 .yema').eq(0).addClass('active');
                }
            }  
        }
    });
    if(user.type==1){
        $('#page5').css('padding-top','50px');
        $('#page5>div').css('display','none');
        $('#xiuGaiGuanLi>div:nth-of-type(3) input').attr('disabled','disabled');
        $('.guanLiLeiXingXiaLa>ul').css('height','27px')
    }
}
function xuanRanGuanLiYuan(){
    var typeName='';
    $('#page5 table').html('');
    $('#page5 table').append('<tr>\
    <th>编号</th>\
    <th>姓名</th>\
    <th>账号</th>\
    <th>类型</th>\
    <th>操作</th>\
</tr>');
    for(var i=(page-1)*count;i<page*count;i++){
        if(i>=arr.length){
            break;
        }
        if(arr[i].type==1){
            typeName='普通管理员';
        }else if(arr[i].type==2){
            typeName='超级管理员';
        }
        $('#page5 table').append('<tr>\
        <td data-pass="'+arr[i].password+'">'+arr[i].id+'</td>\
        <td>'+arr[i].name+'</td>\
        <td>'+arr[i].userId+'</td>\
        <td>'+typeName+'</td>\
        <td><a href="javascript:;">删除</a>&nbsp;<a href="javascript:;">修改</a></td>\
    </tr>');
    }
    if(user.type==1){
        $('#page5 table').html('');
        $('#page5 table').append('<tr>\
        <th>编号</th>\
        <th>姓名</th>\
        <th>账号</th>\
        <th>类型</th>\
        <th>操作</th>\
    </tr>');
        for(var i=0;i<arr.length;i++){
            if(arr[i].userId==user.userId){
                if(arr[i].type==1){
                    typeName='普通管理员';
                }else if(arr[i].type==2){
                    typeName='超级管理员';
                }
                $('#page5 table').append('<tr>\
                <td data-pass="'+arr[i].password+'">'+arr[i].id+'</td>\
                <td>'+arr[i].name+'</td>\
                <td>'+arr[i].userId+'</td>\
                <td>'+typeName+'</td>\
                <td><a href="javascript:;"></a>&nbsp;<a href="javascript:;">修改</a></td>\
            </tr>');
                $('.guanLiLeiXingXiaLa>ul').html('');
                $('.guanLiLeiXingXiaLa>ul').append('<li>普通管理员</li>');
                break;
            }
        }
    }
}
$('#page2 div a:first-of-type').on('click',function(){
    arr=[]
    count=5;
    page=1;
    var str=$('#page2 div input').val();
    $('#page2 div input').val('');
    $.ajax({
        url:'/api/dorm/getdorm',
        success:function(res){
            if(res.data.length){
                $.each(res.data,function(i,v){
                    if(!v.dormName){
                        v.dormName+='';
                    }
                    if(v.dormName.indexOf(str)>=0){
                        arr.push(v);
                    }
                });
                creatYeMa(2);
                xuanRanSuShe();
                $('#page2 .yema').removeClass('active');
                $('#page2 .yema').eq(0).addClass('active');
            }  
        }
    });
});
$('#page2 div a:nth-of-type(2)').on('click',function(){
    suSheGuanLi();
});
$('.s1>div>div>input').on('blur',function(){
    var str=$(this).val();
    if(!str){
        $('.yanZheng').text('输入内容不能为空')
    }else{
        $('.yanZheng').text('');
    }
});
$('#page2 div a:last-of-type').on('click',function(){
    $('#page2-tianJiaSuShe').css('display','block');
    getPosition($('#tianJiaSuShe'));
    dormIdArr=[]
    $.ajax({
        url:'/api/dorm/getdorm',
        success:function(res){
            if(res.data.length){
                $.each(res.data,function(i,v){
                    dormIdArr.push(v.dormId);
                });
            }  
        }
    }); 
});
$('.s2>div>div>div:first-of-type>a').on('click',function(){
    $(this).parent().parent().css({
        'left':chuShiPosition.left-chuShiMargin.left+'px',
        'top':chuShiPosition.top-chuShiMargin.top+'px'
    })
    $(this).parent().parent().parent().css('display','none');
    $('.inputBox input').val('');
    $('.suoShuSuSheXiaLa').css('display','none');
    $('.guanLiLeiXingXiaLa').css('display','none');
    $('.suoShuSuShe>a>span:first-of-type').text('请选择学生所属宿舍');
    $('.suoShuSuShe>a>span:first-of-type').addClass('chuShiSuShe');
    $('.suoShuSuShe').next().text('');
    $('.test').text('');
});
$('.s2>div>div>div:last-of-type button:first-of-type').on('click',function(){
    $(this).parent().parent().css({
        'left':chuShiPosition.left-chuShiMargin.left+'px',
        'top':chuShiPosition.top-chuShiMargin.top+'px'
    })
    $(this).parent().parent().parent().css('display','none');
    $('.inputBox input').val('');
    $('.suoShuSuSheXiaLa').css('display','none');
    $('.guanLiLeiXingXiaLa').css('display','none');
    $('.suoShuSuShe>a>span:first-of-type').text('请选择学生所属宿舍');
    $('.suoShuSuShe>a>span:first-of-type').addClass('chuShiSuShe');
    $('.suoShuSuShe').next().text('');
    $('.test').text('');
});
$('#tianJiaSuShe>div:last-of-type button:last-of-type').on('click',function(){
    for(var i=0;i<$('#tianJiaSuShe input').length;i++){
        if($('#tianJiaSuShe input').eq(i).val()==''){
            $('#tianJiaSuShe input').eq(i).next().text('输入内容不能为空');
        }
    }
    if(!($('.test').text())){
        $.ajax({
            url:'/api/dorm/adddorm',
            data:{
                balance:$('#tianJiaSuShe>div:nth-of-type(4)>input').val(),
                dormId:$('#tianJiaSuShe>div:nth-of-type(2)>input').val(),
                dormName:$('#tianJiaSuShe>div:nth-of-type(3)>input').val()
            },
            type:'post',
            success:function(res){
                if(res.code==200){
                    $('#page2-tianJiaSuShe').css('display','none');
                    $('#page2-tianJiaSuShe').css({
                        'left':chuShiPosition.left-chuShiMargin.left+'px',
                        'top':chuShiPosition.top-chuShiMargin.top+'px'
                    })
                    $('.inputBox input').val('');
                    suSheGuanLi();
                    $('#tiShi').text('添加宿舍成功');
                    tiShi();
                }
            }
        });
    }
});
function tiShi(){
    $('#tiShi').css('display','block');
    $('#tiShi').animate({
        top:"18px"
    },2000,function(){
        $('#tiShi').text('');
        $('#tiShi').css('display','none');
    });
}
$('#page2 table').on('click','a:first-of-type',function(){
    $('#page2-shanChuSuShe').css('display','block');
    getPosition($('#shanChuSuShe'));
    getId=$(this).parent().parent().children().first().attr('data-id');
});
$('#shanChuSuShe>div:last-of-type button:last-of-type').on('click',function(){
    $.ajax({
        url:'/api/dorm/deldorm',
        data:{
            dormId:getId
        },
        type:'post',
        success:function(res){
            if(res.code==200){
                $('#page2-shanChuSuShe').css('display','none');
                $('#page2-shanChuSuShe').css({
                    'left':chuShiPosition.left-chuShiMargin.left+'px',
                    'top':chuShiPosition.top-chuShiMargin.top+'px'
                });
                $('.inputBox input').val('');
                suSheGuanLi();
                $('#tiShi').text('删除宿舍成功');
                tiShi();
            }
        }
    });
});
$('#page2 table').on('click','a:nth-of-type(2)',function(){
    $('#page2-xiuGaiSuShe').css('display','block');
    getPosition($('#xiuGaiSuShe'));
    getId=$(this).parent().parent().children().first().attr('data-id');
    $('#xiuGaiSuShe>div:nth-of-type(2) input').val($(this).parent().parent().children().first().text());
    $('#xiuGaiSuShe>div:nth-of-type(3) input').val($(this).parent().parent().children().eq(1).text());
    $('#xiuGaiSuShe>div:nth-of-type(4) input').val($(this).parent().parent().children().eq(2).text());
    $('#xiuGaiSuShe>div:nth-of-type(5) input').val($(this).parent().parent().children().eq(3).text());
});
$('#xiuGaiSuShe>div:last-of-type button:last-of-type').on('click',function(){
    for(var i=0;i<$('#xiuGaiSuShe input').length;i++){
        if($('#xiuGaiSuShe input').eq(i).val()==''){
            $('#xiuGaiSuShe input').eq(i).next().text('输入内容不能为空');
        }
    }
    if(!($('.test').text())){
        $.ajax({
            url:'/api/dorm/updatedorm',
            data:{
                balance:$('#xiuGaiSuShe>div:nth-of-type(5) input').val(),
                dormId: $('#xiuGaiSuShe>div:nth-of-type(2) input').val(),
                dormName:$('#xiuGaiSuShe>div:nth-of-type(3) input').val(),
                id:getId,
                num:$('#xiuGaiSuShe>div:nth-of-type(3) input').val(),
            },
            type:'post',
            success:function(res){
                if(res.code==200){
                    $('#page2-xiuGaiSuShe').css('display','none');
                    $('#page2-xiuGaiSuShe').css({
                        'left':chuShiPosition.left-chuShiMargin.left+'px',
                        'top':chuShiPosition.top-chuShiMargin.top+'px'
                    });
                    $('.inputBox input').val('');
                    suSheGuanLi();
                    $('#tiShi').text('修改宿舍成功');
                    tiShi();
                }
            }
        });
    }
});
$('.s2>div>div>div>input').on('blur',function (){
    var str=$(this).val();
    var reg=/^\d+$/;
    var boolean=true;
    if(!str){
        $(this).next().text('输入内容不能为空');
        boolean=false;
    }else if($(this).attr('placeholder')=='仅支持数值类型'){
        if(reg.test(str)&&($(this).next().text()=='输入内容不能为空'||'输入内容必须是数字'||'')){
            $(this).next().text('');
        }else{
            $(this).next().text('输入内容必须是数字');
            boolean=false;
        }
    }else if($(this).next().text()=='输入内容不能为空'||'输入内容必须是数字'||''){
        $(this).next().text('');
    }
    if((!($('#tianJiaSuShe input:first-of-type').val()==''))&&boolean==true){
        for(var i=0;i<dormIdArr.length;i++){
            if($('#tianJiaSuShe>div:nth-of-type(2)>input').val()==dormIdArr[i]){
                $('#tianJiaSuShe>div:nth-of-type(2)>input').next().text('该宿舍编号已存在，请重新输入');
            }
        }
    }
    if((!($('#tianJiaXueSheng input:first-of-type').val()==''))&&boolean==true){
        for(var i=0;i<stuIdArr.length;i++){
            if($('#tianJiaXueSheng>div:nth-of-type(2)>input').val()==stuIdArr[i]){
                $('#tianJiaXueSheng>div:nth-of-type(2)>input').next().text('该学生学号已存在，请重新输入');
            }
        }
    }
    if((!($('#tianJiaGuanLi>div:nth-of-type(3)>input').val()==''))&&boolean==true){
        for(var i=0;i<userIdArr.length;i++){
            if($('#tianJiaGuanLi>div:nth-of-type(3)>input').val()==userIdArr[i]){
                $('#tianJiaGuanLi>div:nth-of-type(3)>input').next().text('该账号已存在，请重新输入');
            }
        }
    }
});
$('#page2 table').on('click','a:last-of-type',function(){
    $('#page2-cuiKuan').css('display','block');
    getPosition($('#cuiKuan'));
    getId=$(this).parent().parent().children().first().attr('data-id');
    getType=$(this).parent().parent().children().eq(4).text();
    if(getType=='正常'){
        $('.cuiKuanText').text('确认发起催款请求吗');
    }else{
        $('.cuiKuanText').text('确认取消催款请求吗');
    }
});
$('#cuiKuan>div:last-of-type button:last-of-type').on('click',function(){
    var typeValue='';
    if(getType=='正常'){
        typeValue=2;
    }else{
        typeValue=1;
    }
    $.ajax({
        url:'/api/dorm/deptdorm',
        data:{
            id:getId,
            type:typeValue
        },
        type:'post',
        success:function(res){
            if(res.code==200){
                $('#page2-cuiKuan').css('display','none');
                $('#cuiKuan').css({
                    'left':chuShiPosition.left-chuShiMargin.left+'px',
                    'top':chuShiPosition.top-chuShiMargin.top+'px'
                });
                $('.inputBox input').val('');
                suSheGuanLi();
                if(typeValue==2){
                    $('#tiShi').text('发送催款请求成功');
                }else{
                    $('#tiShi').text('取消催款请求成功');
                }
                tiShi();
            }
        }
    });
});
$('#page3 div a:first-of-type').on('click',function(){
    arr=[]
    count=5;
    page=1;
    var str=$('#page3 div input').val();
    $('#page3 div input').val('');
    $.ajax({
        url:'/api/student/getstudent',
        success:function(res){
            if(res.data.length){
                $.each(res.data,function(i,v){
                    if(!v.stuName){
                        v.stuName+='';
                    }
                    if(v.stuName.indexOf(str)>=0){
                        arr.push(v);
                    }
                });
                creatYeMa(3);
                xuanRanXueSheng();
                $('#page3 .yema').removeClass('active');
                $('#page3 .yema').eq(0).addClass('active');
            }  
        }
    });
});
$('#page3 div a:nth-of-type(2)').on('click',function(){
    xueShengGuanLi();
});
$('#page3 div a:last-of-type').on('click',function(){
    $('.suoShuSuShe>a>span:first-of-type').text('请选择学生所属宿舍');
    $('.suoShuSuShe>a>span:first-of-type').addClass('chuShiSuShe');
    $('#page3-tianJiaXueSheng').css('display','block');
    getPosition($('#tianJiaXueSheng'));
    $('.suoShuSuShe').next().text('');
    stuIdArr=[]
    $.ajax({
        url:'/api/student/getstudent',
        success:function(res){
            if(res.data.length){
                $.each(res.data,function(i,v){
                    stuIdArr.push(v.stuId);
                });
            }  
        }
    }); 
});
$('#tianJiaXueSheng>div:last-of-type button:last-of-type').on('click',function(){
    for(var i=0;i<$('#tianJiaXueSheng input').length;i++){
        if($('#tianJiaXueSheng input').eq(i).val()==''){
            $('#tianJiaXueSheng input').eq(i).next().text('输入内容不能为空');
        }
    }
    if($('.suoShuSuShe>a>span:first-of-type').attr('class').indexOf('chuShiSuShe')>=0){
        $('.suoShuSuShe').next().text('请选择学生所属宿舍');
    }else{
        $('.suoShuSuShe').next().text('');
    }
    if(!($('.test').text())){
        $.each(allSuShe,function(i,v){
            if($('.suoShuText').text()==v.dormId){
                getId=v.id;
                return;
            }
        });
        $.ajax({
            url:'/api/student/addstudent',
            data:{
                stuDormId:getId,
                stuId:$('#tianJiaXueSheng>div:nth-of-type(2)>input').val(),
                stuName:$('#tianJiaXueSheng>div:nth-of-type(3)>input').val(),
                stuPas:$('#tianJiaXueSheng>div:nth-of-type(5)>input').val(),
                stuUserId:$('#tianJiaXueSheng>div:nth-of-type(4)>input').val()
            },
            type:'post',
            success:function(res){
                if(res.code==200){
                    $('#page3-tianJiaXueSheng').css('display','none');
                    $('#page3-tianJiaXueSheng').css({
                        'left':chuShiPosition.left-chuShiMargin.left+'px',
                        'top':chuShiPosition.top-chuShiMargin.top+'px'
                    });
                    $('.inputBox input').val('');
                    xueShengGuanLi();
                    $('#tiShi').text('添加学生成功');
                    tiShi();
                    $('.suoShuSuShe>a>span:first-of-type').text('请选择学生所属宿舍');
                    $('.suoShuSuShe>a>span:first-of-type').addClass('chuShiSuShe');
                    $('.suoShuSuShe').next().text('');
                }
            }
        });
    }
});
$('.suoShuSuShe>a').on('click',function(){
    $('.suoShuSuSheXiaLa').toggle();
})
$('.suoShuSuSheXiaLa').on('click','li',function(){
    $('.suoShuText').text($(this).text());
    $('.suoShuText2').text($(this).text());
    $('.suoShuSuShe>a>span:first-of-type').removeClass('chuShiSuShe');
    $('.suoShuSuShe').next().text('');
    $('.suoShuSuSheXiaLa').hide();
})
$('#page3 table').on('click','a:first-of-type',function(){
    $('#page3-shanChuXueSheng').css('display','block');
    getId=$(this).parent().parent().children().first().attr('data-id');
    getPosition($('#shanChuXueSheng'));
});
$('#shanChuXueSheng>div:last-of-type button:last-of-type').on('click',function(){
    $.ajax({
        url:'/api/student/delstudent',
        data:{
            id:getId
        },
        type:'post',
        success:function(res){
            if(res.code==200){
                $('#page3-shanChuXueSheng').css('display','none');
                $('#page3-tianJiaXueSheng').css({
                    'left':chuShiPosition.left-chuShiMargin.left+'px',
                    'top':chuShiPosition.top-chuShiMargin.top+'px'
                });
                $('.inputBox input').val('');
                xueShengGuanLi();
                $('#tiShi').text('删除学生成功');
                tiShi();
            }
        }
    });
});
$('#page3 table').on('click','a:nth-of-type(2)',function(){
    $('#page3-xiuGaiXueSheng').css('display','block');
    getPosition($('#xiuGaiXueSheng'));
    getId=$(this).parent().parent().children().first().attr('data-id');
    $('#xiuGaiXueSheng>div:nth-of-type(2) input').val($(this).parent().parent().children().first().text());
    $('#xiuGaiXueSheng>div:nth-of-type(3) input').val($(this).parent().parent().children().eq(1).text());
    $('#xiuGaiXueSheng>div:nth-of-type(4) input').val($(this).parent().parent().children().eq(2).text());
    $('#xiuGaiXueSheng>div:nth-of-type(5) input').val($(this).parent().parent().children().first().attr('data-pass'));
    $('.suoShuText2').text($(this).parent().parent().children().eq(3).text())
});
$('#xiuGaiXueSheng>div:last-of-type button:last-of-type').on('click',function(){
    for(var i=0;i<$('#xiuGaiXueSheng input').length;i++){
        if($('#xiuGaiXueSheng input').eq(i).val()==''){
            $('#xiuGaiXueSheng input').eq(i).next().text('输入内容不能为空');
        }
    }
    if(!($('.test').text())){
        var getDormId=0;
        $.each(allSuShe,function(i,v){
            if($('.suoShuText2').text()==v.dormId){
                getDormId=v.id;
                return;
            }
        });
        $.ajax({
            url:'/api/student/updatestudent',
            data:{
                id:getId,
                stuDormId:getDormId,
                stuName:$('#xiuGaiXueSheng>div:nth-of-type(3) input').val(),
                stuPas:$('#xiuGaiXueSheng>div:nth-of-type(5) input').val(),
            },
            type:'post',
            success:function(res){
                if(res.code==200){
                    $('#page3-xiuGaiXueSheng').css('display','none');
                    $('#page3-xiuGaiXueSheng').css({
                        'left':chuShiPosition.left-chuShiMargin.left+'px',
                        'top':chuShiPosition.top-chuShiMargin.top+'px'
                    });
                    $('.inputBox input').val('');
                    xueShengGuanLi();
                    $('#tiShi').text('修改宿舍成功');
                    tiShi();
                }
            }
        });
    }
});
$('#page3 table').on('click','a:last-of-type',function(){
    $('#page3-chaKan').css('display','block');
    getPosition($('#chaKan'));
    getId=$(this).parent().parent().children().first().attr('data-id');
    $.ajax({
        url:'/api/student/getstudentpayment',
        data:{
            id:getId
        },
        success:function(res){
            $('#chaKan table').html('');
            $('#chaKan table').append('<tr>\
            <th>缴费金额</th>\
            <th>缴费时间</th>\
        </tr>');
            for(var i=0;i<res.data.length;i++){
                $('#chaKan table').append('<tr>\
                <td>'+res.data[i].money+'</td>\
                <td>'+res.data[i].mytime+'</td>\
            </tr>')
            }
        }
    });
});
$('#chaKan>div:last-of-type button:last-of-type').on('click',function(){
    $('#page3-chaKan').css('display','none');
    $('#page3-chaKan').css({
        'left':chuShiPosition.left-chuShiMargin.left+'px',
        'top':chuShiPosition.top-chuShiMargin.top+'px'
    });
});
$('#page4 div a:first-of-type').on('click',function(){
    arr=[]
    count=5;
    page=1;
    var str=$('#page4 div input').val();
    $('#page4 div input').val('');
    $.ajax({
        url:'/api/notice/getnotice',
        success:function(res){
            if(res.data.length){
                $.each(res.data,function(i,v){
                    if(!v.title){
                        v.title+='';
                    }
                    if(v.title.indexOf(str)>=0){
                        arr.push(v);
                    }
                });
                creatYeMa(4);
                xuanRanGongGao2();
                $('#page4 .yema').removeClass('active');
                $('#page4 .yema').eq(0).addClass('active');
            }  
        }
    });
});
$('#page4 div a:nth-of-type(2)').on('click',function(){
    gongGaoGuanLi();
});
$('#page4 div a:last-of-type').on('click',function(){
    $('#page4-tianJiaGongGao').css('display','block');
    getPosition($('#tianJiaGongGao'))
});
$('#tianJiaGongGao>div:last-of-type button:last-of-type').on('click',function(){
    if($('#tianJiaGongGao input').val()==''){
        $('#tianJiaGongGao input').next().text('输入内容不能为空');
    }
    if($('#tianJiaGongGao textarea').val()==''){
        $('#tianJiaGongGao textarea').next().val('输入内容不能为空');
    }
    if(!($('.test').text())){
        $.ajax({
            url:'/api/notice/addnotice',
            data:{
                content:$('#tianJiaGongGao textarea').val(),
                title:$('#tianJiaGongGao input').val(),
                userId:JSON.parse(sessionStorage.getItem('user')).id
            },
            type:'post',
            success:function(res){
                if(res.code==200){
                    $('#page4-tianJiaGongGao').css('display','none');
                    $('#page4-tianJiaGongGao').css({
                        'left':chuShiPosition.left-chuShiMargin.left+'px',
                        'top':chuShiPosition.top-chuShiMargin.top+'px'
                    });
                    $('.inputBox input').val('');
                    gongGaoGuanLi();
                    $('#tiShi').text('添加公告成功');
                    tiShi();
                }
            }
        });
    }
});
$('#page4 table').on('click','a:first-of-type',function(){
    $('#page4-shanChuGongGao').css('display','block');
    getPosition($('#shanChuGongGao'));
    getId=$(this).parent().parent().children().first().text();
});
$('#shanChuGongGao>div:last-of-type button:last-of-type').on('click',function(){
    $.ajax({
        url:'/api/notice/delnotice',
        data:{
            id:getId
        },
        type:'post',
        success:function(res){
            if(res.code==200){
                $('#page4-shanChuGongGao').css('display','none');
                $('#page4-shanChuGongGao').css({
                    'left':chuShiPosition.left-chuShiMargin.left+'px',
                    'top':chuShiPosition.top-chuShiMargin.top+'px'
                });
                $('.inputBox input').val('');
                gongGaoGuanLi();
                $('#tiShi').text('删除公告成功');
                tiShi();
            }
        }
    });
});
$('#page4 table').on('click','a:nth-of-type(2)',function(){
    $('#page4-xiuGaiGongGao').css('display','block');
    getPosition($('#xiuGaiGongGao'));
    $('#xiuGaiGongGao>div:nth-of-type(2) input').val($(this).parent().parent().children().first().text());
    $('#xiuGaiGongGao>div:nth-of-type(3) input').val($(this).parent().parent().children().eq(1).text());
    $('#xiuGaiGongGao>div:nth-of-type(4) textarea').val($(this).parent().parent().children().eq(2).children().text());
    $('#xiuGaiGongGao>div:nth-of-type(5) input').val($(this).parent().parent().children().eq(3).text());
    $('#xiuGaiGongGao>div:nth-of-type(6) input').val($(this).parent().parent().children().eq(4).text());
});
$('#xiuGaiGongGao>div:last-of-type button:last-of-type').on('click',function(){
    for(var i=0;i<$('#xiuGaiGongGao input').length;i++){
        if($('#xiuGaiGongGao input').eq(i).val()==''){
            $('#xiuGaiGongGao input').eq(i).next().text('输入内容不能为空');
        }
    }
    if($('#xiuGaiGongGao textarea').val()==''){
        $('#xiuGaiGongGao textarea').next().val('输入内容不能为空');
    }
    if(!($('.test').text())){
        $.ajax({
            url:'/api/notice/updatenotice',
            data:{
                content:$('#xiuGaiGongGao textarea').val(),
                title: $('#xiuGaiGongGao>div:nth-of-type(3) input').val(),
                id: $('#xiuGaiGongGao>div:nth-of-type(2) input').val()
            },
            type:'post',
            success:function(res){
                if(res.code==200){
                    $('#page4-xiuGaiGongGao').css('display','none');
                    $('#page4-xiuGaiGongGao').css({
                        'left':chuShiPosition.left-chuShiMargin.left+'px',
                        'top':chuShiPosition.top-chuShiMargin.top+'px'
                    });
                    $('.inputBox input').val('');
                    gongGaoGuanLi();
                    $('#tiShi').text('修改公告成功');
                    tiShi();
                }
            }
        });
    }
});
$('#page5 div a:first-of-type').on('click',function(){
    arr=[]
    count=5;
    page=1;
    var str=$('#page5 div input').val();
    $('#page5 div input').val('');
    $.ajax({
        url:'/api/admin/getadmin',
        success:function(res){
            if(res.data.length){
                $.each(res.data,function(i,v){
                    if(!v.name){
                        v.name+='';
                    }
                    if(v.name.indexOf(str)>=0){
                        arr.push(v);
                    }
                });
                creatYeMa(5);
                xuanRanGuanLiYuan();
                $('#page5 .yema').removeClass('active');
                $('#page5 .yema').eq(0).addClass('active');
            }  
        }
    });
});
$('#page5 div a:nth-of-type(2)').on('click',function(){
    guanLiYuanGuanLi();
});
$('#page5 div a:last-of-type').on('click',function(){
    $('#page5-tianJiaGuanLi').css('display','block');
    getPosition($('#tianJiaGuanLi'));
    $('.guanLiLeiXing>a>span:first-of-type').text('请选择管理员类型');
    $('.guanLiLeiXing>a>span:first-of-type').addClass('chuShiLeiXing');
    $('.guanLiLeiXing').next().text('');
    userIdArr=[]
    $.ajax({
        url:'/api/admin/getadmin',
        success:function(res){
            if(res.data.length){
                $.each(res.data,function(i,v){
                    userIdArr.push(v.userId);
                });
            }  
        }
    }); 
});
$('#tianJiaGuanLi>div:last-of-type button:last-of-type').on('click',function(){
    var typeValue=0;
    for(var i=0;i<$('#tianJiaGuanLi input').length;i++){
        if($('#tianJiaGuanLi input').eq(i).val()==''){
            $('#tianJiaGuanLi input').eq(i).next().text('输入内容不能为空');
        }
    }
    if($('.guanLiLeiXing>a>span:first-of-type').attr('class').indexOf('chuShiLeiXing')>=0){
        $('.guanLiLeiXing').next().text('请选择管理员类型');
    }else{
        $('.guanLiLeiXing').next().text('');
    }
    if($('#tianJiaGuanLi .leiXingText').text()=='普通管理员'){
        typeValue=1;
    }else{
        typeValue=2;
    }
    if(!($('.test').text())){
        $.ajax({
            url:'/api/admin/addadmin',
            data:{
                name:$('#tianJiaGuanLi input').eq(0).val(),
                password:$('#tianJiaGuanLi input').eq(2).val(),
                type:typeValue,
                userId:$('#tianJiaGuanLi input').eq(1).val()
            },
            type:'post',
            success:function(res){
                if(res.code==200){
                    $('#page5-tianJiaGuanLi').css('display','none');
                    $('#page5-tianJiaGuanLi').css({
                        'left':chuShiPosition.left-chuShiMargin.left+'px',
                        'top':chuShiPosition.top-chuShiMargin.top+'px'
                    });
                    $('.inputBox input').val('');
                    guanLiYuanGuanLi();
                    $('#tiShi').text('添加管理员成功');
                    tiShi();
                }
            }
        });
    }
});
$('.guanLiLeiXing').on('click',function(){
    $('.guanLiLeiXingXiaLa').toggle();
});
$('.guanLiLeiXingXiaLa li').on('click',function(){
    $('.leiXingText').text($(this).text());
    $('.guanLiLeiXing>a>span:first-of-type').removeClass('chuShiLeiXing');
    $('.guanLiLeiXing').next().text('');
});
$('#page5 table').on('click','a:first-of-type',function(){
    $('#page5-shanChuGuanLi').css('display','block');
    getPosition($('#shanChuGuanLi'));
    getId=$(this).parent().parent().children().first().text();
});
$('#shanChuGuanLi>div:last-of-type button:last-of-type').on('click',function(){
    $.ajax({
        url:'/api/admin/deladmin',
        data:{
            id:getId
        },
        type:'post',
        success:function(res){
            if(res.code==200){
                $('#page5-shanChuGuanLi').css('display','none');
                $('#page5-shanChuGuanLi').css({
                    'left':chuShiPosition.left-chuShiMargin.left+'px',
                    'top':chuShiPosition.top-chuShiMargin.top+'px'
                });
                $('.inputBox input').val('');
                guanLiYuanGuanLi();
                $('#tiShi').text('删除管理员成功');
                tiShi();
            }
        }
    });
});
$('#page5 table').on('click','a:last-of-type',function(){
    $('#page5-xiuGaiGuanLi').css('display','block');
    getPosition($('#xiuGaiGuanLi'));
    $('#xiuGaiGuanLi input').eq(0).val($(this).parent().parent().children().eq(0).text());
    $('#xiuGaiGuanLi input').eq(1).val($(this).parent().parent().children().eq(1).text());
    $('#xiuGaiGuanLi input').eq(2).val($(this).parent().parent().children().eq(2).text());
    $('#xiuGaiGuanLi input').eq(3).val($(this).parent().parent().children().eq(0).attr('data-pass'));
    $('#xiuGaiGuanLi .guanLiLeiXing>a>span:first-of-type').text($(this).parent().parent().children().eq(3).text());
});
$('#xiuGaiGuanLi>div:last-of-type button:last-of-type').on('click',function(){
    for(var i=0;i<$('#xiuGaiGuanLi input').length;i++){
        if($('#xiuGaiGuanLi input').eq(i).val()==''){
            $('#xiuGaiGuanLi input').eq(i).next().text('输入内容不能为空');
        }
    }
    if(!($('.test').text())){
        var typeValue='';
        if($('#xiuGaiGuanLi .guanLiLeiXing>a>span:first-of-type').text()=='普通管理员'){
            typeValue=1;
        }else{
            typeValue=2;
        }
        $.ajax({
            url:'/api/admin/updateadmin',
            data:{
                id: $('#xiuGaiGuanLi input').eq(0).val(),
                name: $('#xiuGaiGuanLi input').eq(1).val(),
                password: $('#xiuGaiGuanLi input').eq(3).val(),
                type: typeValue  
            },
            type:'post',
            success:function(res){
                if(res.code==200){
                    $('#page5-xiuGaiGuanLi').css('display','none');
                    $('#page5-xiuGaiGuanLi').css({
                        'left':chuShiPosition.left-chuShiMargin.left+'px',
                        'top':chuShiPosition.top-chuShiMargin.top+'px'
                    });
                    $('.inputBox input').val('');
                    guanLiYuanGuanLi();
                    $('#tiShi').text('修改管理员成功');
                    tiShi();
                }
            }
        });
    }
});
var tuoZhuaiObj={};
var disX=0;
var disY=0;
var oldL=0;
var oldT=0;
var oldW=0;
var oldH=0;
$('.s2>div>div').on('mousedown',tuoZhuai);
function tuoZhuai(){
    tuoZhuaiObj=$(this);
    oldW=tuoZhuaiObj.width();
    oldH=tuoZhuaiObj.height();
    oldL=tuoZhuaiObj.offset().left;
    oldT=tuoZhuaiObj.offset().top;
    disX=event.pageX-oldL;
    disY=event.pageY-oldT;
    $(document).on('mousemove',fnMove);
    $(document).on('mouseup',fnUp);
}
$('input').on('mouseover',function(){
    $('.s2>div>div').off('mousedown',tuoZhuai);
});
$('input').on('mouseout',function(){
    $('.s2>div>div').on('mousedown',tuoZhuai);
});
$('textarea').on('mouseover',function(){
    $('.s2>div>div').off('mousedown',tuoZhuai);
});
$('textarea').on('mouseout',function(){
    $('.s2>div>div').on('mousedown',tuoZhuai);
});
function fnMove(){
    if(event.pageX-disX>0&&event.pageX-disX<document.documentElement.clientWidth-oldW){
        tuoZhuaiObj.css('left',event.pageX-disX-chuShiMargin.left+'px')
    }else if(event.pageX-disX<=0){
        tuoZhuaiObj.css('left',-chuShiMargin.left+'px')
    }else if(event.pageX-disX>=document.documentElement.clientWidth-oldW){
        tuoZhuaiObj.css('left',document.documentElement.clientWidth-oldW-chuShiMargin.left+'px')
    }
    if(event.pageY-disY>0&&event.pageY-disY<document.documentElement.clientHeight-oldH){
        tuoZhuaiObj.css('top',event.pageY-disY-chuShiMargin.top+'px')
    }else if(event.pageY-disY<=0){
        tuoZhuaiObj.css('top',-chuShiMargin.top+'px')
    }else if(event.pageY-disY>=document.documentElement.clientHeight-oldH){
        tuoZhuaiObj.css('top',document.documentElement.clientHeight-oldH-chuShiMargin.top+'px')
    }
}
function fnUp(){
    tuoZhuaiObj={};
    $(document).off('mousemove',fnMove);
    $(document).off('mouseup',fnUp); 
}
function getPosition(obj){
    chuShiPosition.left=obj.offset().left;
    chuShiPosition.top=obj.offset().top;
    chuShiMargin.left=parseInt(obj.css('margin-left'));
    chuShiMargin.top=parseInt(obj.css('margin-top'));
}
(function(){
    if(!user.type){
        $('.menu>ul>li').eq(1).css('display','none');
        $('.menu>ul>li').eq(3).css('display','none');
        $('.menu>ul>li').eq(4).css('display','none');
        $('#page3>nav').css('display','none');
    }else if(user.type==1){
        $('#page5>nav').css('display','none');
    }
    $('#j-name').text(user.name);
})();
$('#j-user').on('click',function(){
    $('.j-exitcss').toggle();
});
$('#j-name').on('click',function(){
    $('.j-exitcss').toggle();
});
$('.j-exit').on('click',function(){
    sessionStorage.removeItem('user');
    removeCookie('user');
    window.name='';
    window.location.href='login.html';
});
function setCookie(name,value,expires){
    if(expires){
        var oDate=new Date();
        oDate.setDate(oDate.getDate()+expires);
        document.cookie=name+'='+value+';path=/;expires='+oDate;
    }else{
        document.cookie=name+'='+value+';path=/';
    }
}
function removeCookie(name){
    setCookie(name,'',-1)
}
$('.biaoqianye').on('click','.j-del',function(event){
    event.stopPropagation();
    $(this).parents('li').remove();
    if($('.biaoqianye').children().length<=1){
        $('.s1>div').css('display','none');
        $('#page1').css('display','block');
        gongGaoZhuYe();
        $('.biaoqianye>li').attr('data-class','');
        $('.index1').attr('data-class','active');
    }else{
        var index=$('.biaoqianye').children().eq($('.biaoqianye').children().length-2).attr('class')[5];
        $('.s1>div').css('display','none');
        $('#page'+index).css('display','block');
        $('.biaoqianye>li').attr('data-class','');
        $('.index'+index).attr('data-class','active');
    }
});
$('.biaoqianye').on('click','.index1',function(){
    $('.s1>div').css('display','none');
    $('#page1').css('display','block');
    gongGaoZhuYe();
    $('.biaoqianye>li').attr('data-class','');
    $(this).attr('data-class','active');
});
$('.biaoqianye').on('click','.index2',function(){
    $('.s1>div').css('display','none');
    $('#page2').css('display','block');
    suSheGuanLi();
    $('.biaoqianye>li').attr('data-class','');
    $(this).attr('data-class','active');
});
$('.biaoqianye').on('click','.index3',function(){
    $('.s1>div').css('display','none');
    $('#page3').css('display','block');
    xueShengGuanLi();
    $('.biaoqianye>li').attr('data-class','');
    $(this).attr('data-class','active');
});
$('.biaoqianye').on('click','.index4',function(){
    $('.s1>div').css('display','none');
    $('#page4').css('display','block');
    gongGaoGuanLi();
    $('.biaoqianye>li').attr('data-class','');
    $(this).attr('data-class','active');
});
$('.biaoqianye').on('click','.index5',function(){
    $('.s1>div').css('display','none');
    $('#page5').css('display','block');
    guanLiYuanGuanLi();
    $('.biaoqianye>li').attr('data-class','');
    $(this).attr('data-class','active');
});
$('.j-biaoQian').on('click',function(){
    $('.j-biaoQianXiaLa').toggle();
});
$('.j-biaoQianXiaLa').children().eq(0).on('click',function(){
    while($('.biaoqianye').children().length>1){
        $('.biaoqianye').children().first().remove();
    }
    $('.s1>div').css('display','none');
    $('#page1').css('display','block');
    gongGaoZhuYe();
    $('.biaoqianye>li').attr('data-class','');
    $('.index1').attr('data-class','active');
    $('.j-biaoQianXiaLa').hide();
});
$('.j-biaoQianXiaLa').children().eq(1).on('click',function(){
    var i=0;
    while($('.biaoqianye').children().length>2){
        if(!$('.biaoqianye').children().eq(i).attr('data-class')){
            $('.biaoqianye').children().eq(i).remove();
        }else{
            i++
        }
    }
    $('.j-biaoQianXiaLa').hide();
});
$('.j-biaoQianXiaLa').children().eq(2).on('click',function(){
    for(var i=0;i<$('.biaoqianye').children().length-1;i++){
        if($('.biaoqianye').children().eq(i).attr('data-class')){
            $('.biaoqianye').children().eq(i).remove();
        }
    }
    if($('.biaoqianye').children().length<=1){
        $('.s1>div').css('display','none');
        $('#page1').css('display','block');
        gongGaoZhuYe();
        $('.biaoqianye>li').attr('data-class','');
        $('.index1').attr('data-class','active');
    }else{
        var index=$('.biaoqianye').children().eq($('.biaoqianye').children().length-2).attr('class')[5];
        $('.s1>div').css('display','none');
        $('#page'+index).css('display','block');
        $('.biaoqianye>li').attr('data-class','');
        $('.index'+index).attr('data-class','active');
    }
    $('.j-biaoQianXiaLa').hide();
});
//进行切换
var fullScreenClickCount=0; 
//调用各个浏览器提供的全屏方法
var handleFullScreen = function () {
    var de = document.documentElement;

    if (de.requestFullscreen) {
        de.requestFullscreen();
    } else if (de.mozRequestFullScreen) {
        de.mozRequestFullScreen();
    } else if (de.webkitRequestFullScreen) {
        de.webkitRequestFullScreen();
    } else if (de.msRequestFullscreen) {
        de.msRequestFullscreen();
    }
    else {
        wtx.info("当前浏览器不支持全屏！");
    }

};
//调用各个浏览器提供的退出全屏方法
var exitFullscreen=function() {
    if(document.exitFullscreen) {
        document.exitFullscreen();
    } else if(document.mozCancelFullScreen) {
        document.mozCancelFullScreen();
    } else if(document.webkitExitFullscreen) {
        document.webkitExitFullscreen();
    }
}
$('.fullscreen').on('click',function(){
    if (fullScreenClickCount % 2 == 0) {
        handleFullScreen();
    } else {
        if(!document.fullscreenElement){
            handleFullScreen();
            fullScreenClickCount++;
        }else{
            exitFullscreen();
        }
    }
    fullScreenClickCount++;
});